package com.plantplaces.dao;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class NetworkDAO implements INetworkDAO {

	/* (non-Javadoc)
	 * @see com.plantplaces.dao.INetworkDAO#request(java.lang.String)
	 */
	@Override
	public String request(String uri ) throws ClientProtocolException, Exception {
		String result = "";
		
		// request
		HttpGet httpGet = new HttpGet(uri);

		// handles the response.
		ResponseHandler<String> handler = new BasicResponseHandler();
		
		// join these together.
		HttpClient httpClient = new DefaultHttpClient();
		
		// create a network connection.  Get a result.
		result = httpClient.execute(httpGet, handler);
		
		// return that result.
		return result;
	}
}
